<template>
  <div class="card">
    <el-card class="box-card">
  <div slot="header" class="clearfix">
    <span>修改密码</span>
    
  </div>
  <el-form>
    <el-form-item label="密码:">
      <el-input type="text" placeholder="请输入新密码" style="width:300px" v-model="newValue"></el-input>
    </el-form-item>
  </el-form>
  <el-button style="margin-left:50px;" type="primary" @click="update">修改</el-button>
</el-card>
  </div>
</template>

<script>
import {updatePwd,logout} from '@/api/user'

export default {
    name:'forGotPwd',
    data(){
      return{
        newValue:''
      }
    },
    methods:{
     async update(){
     
      let res=  await updatePwd({newValue:this.newValue})
        if(res.code==200){
          this.$message({
          message: res.message,
          type: 'success'
        });
          await this.$store.dispatch('user/logout')
          this.$router.push(`/login?redirect=${this.$route.fullPath}`)
        }
        
      }
    }
}
</script>

<style scoped>
.card{
  margin-top: 50px;
  margin-left: 100px;
}
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 480px;
  }
</style>